﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using com.kmer.interfaces;

namespace com.kmer.interfaces {
	/// <summary>
	/// 聊天处理
	/// </summary>
	public interface IChatFactory : IFactory {
		/// <summary>
		/// 向用户发送信息
		/// </summary>
		/// <param name="SenderId">发送人ID</param>
		/// <param name="RecvId">接收方ID</param>
		/// <param name="ResType">资源类型（资源类型：1 - 文字、2 - 图片、3 - 视频、4 - 音频）</param>
		/// <param name="ResId">资源ID</param>
		/// <param name="Resources">内容</param>
		/// <param name="UGCID">UGCID(单人聊天ugcid=00000000-0000-0000-0000-000000000000)</param>
		int SendMessageToUser(int SenderId, int RecvId, int ResType, Guid ResId, string Resources, Guid UGCID);

		/// <summary>
		/// 向用户发送信息（异步）
		/// </summary>
		/// <param name="SenderId">发送人ID</param>
		/// <param name="RecvId">接收方ID</param>
		/// <param name="ResType">资源类型（资源类型：1 - 文字、2 - 图片、3 - 视频、4 - 音频）</param>
		/// <param name="ResId">资源ID</param>
		/// <param name="Resources">内容</param>
		/// <param name="UGCID">UGCID(单人聊天ugcid=00000000-0000-0000-0000-000000000000)</param>
		/// <returns></returns>
		Task<int> SendMessageToUserSync(int SenderId, int RecvId, int ResType, Guid ResId, string Resources, Guid UGCID);
	}
	/// <summary>
	/// 聊天处理
	/// </summary>
	public interface IChatSysemFactory : IFactory {
		/// <summary>
		/// 向用户发送信息
		/// </summary>
		/// <param name="SenderId">发送人ID</param>
		/// <param name="RecvId">接收方ID</param>
		/// <param name="ResType">资源类型（资源类型：1 - 文字、2 - 图片、3 - 视频、4 - 音频）</param>
		/// <param name="ResId">资源ID</param>
		/// <param name="Resources">内容</param>
		/// <param name="UGCID">UGCID(单人聊天ugcid=00000000-0000-0000-0000-000000000000)</param>
		/// <param name="IsSendNotice"></param>
		int SendMessage(int SenderId, int RecvId, int ResType, Guid ResId, string Resources, Guid UGCID, bool IsSendNotice = true);
		int SendTextMessage(int SenderId, int RecvId, string Message, bool IsSendNotice = true);
		int SendSystemTextMessage(int RecvId, string Message, bool IsSendNotice = true);

		/// <summary>
		/// 向用户发送信息（异步）
		/// </summary>
		/// <param name="SenderId">发送人ID</param>
		/// <param name="RecvId">接收方ID</param>
		/// <param name="ResType">资源类型（资源类型：1 - 文字、2 - 图片、3 - 视频、4 - 音频）</param>
		/// <param name="ResId">资源ID</param>
		/// <param name="Resources">内容</param>
		/// <param name="UGCID">UGCID(单人聊天ugcid=00000000-0000-0000-0000-000000000000)</param>
		/// <param name="IsSendNotice"></param>
		/// <returns></returns>
		Task<int> SendMessageAsync(int SenderId, int RecvId, int ResType, Guid ResId, string Resources, Guid UGCID, bool IsSendNotice = true);
		Task<int> SendTextMessageAsync(int SenderId, int RecvId, string Message, bool IsSendNotice = true);
		Task<int> SendSystemTextMessageAsync(int RecvId, string Message, bool IsSendNotice = true);
	}
}

namespace com.kmer.Factories {
	public class NullChatFactory : IChatFactory {
		public int SendMessageToUser(int SendId, int RecvId, int ResType, Guid ResId, string Resources, Guid UGCID) {
			//do nothing
			return 0;
		}

		public Task<int> SendMessageToUserSync(int SendId, int RecvId, int ResType, Guid ResId, string Resources, Guid UGCID) {
			//do nothing
			return Task.Run(() => SendMessageToUser(SendId, RecvId, ResType, ResId, Resources, UGCID));
		}
	}
}
